Skip to content

Method: static {...}

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jsonld;
14:
15: /**
16: * Configuration parameters.
17: */
18: public enum ConfigParam {
19:
20: /**
21: * Whether to ignore unknown properties when deserializing JSON-LD.
22: * <p>
23: * If set to {@code false}, an exception will be thrown when unknown property is encountered.
24: */
25: IGNORE_UNKNOWN_PROPERTIES("ignoreUnknownProperties"),
26:
27: /**
28: * Package in which to look for mapped classes.
29: * <p>
30: * The scan is important for support for polymorphism in object deserialization.
31: */
32: SCAN_PACKAGE("scanPackage"),
33:
34: /**
35: * Whether to require an identifier when serializing an object.
36: * <p>
37: * If set to {@code true} and no identifier is found (either there is no identifier field or its value is {@code
38: * null}), an exception will be thrown. If configured to {@code false}, a blank node identifier is generated if no
39: * id is present.
40: */
41: REQUIRE_ID("requireId"),
42:
43: /**
44: * Allows assuming target type from the provided Java type when no types are specified in JSON-LD.
45: * <p>
46: * If set to {@code true}, JB4JSON-LD will attempt to use the provided Java type as the target type when
47: * deserializing a JSON-LD object which has no types declared.
48: * <p>
49: * Defaults to {@code false}, in which case an exception is thrown for a typeless JSON-LD object.
50: */
51: ASSUME_TARGET_TYPE("assumeTargetType"),
52:
53: /**
54: * Enables optimistic target type resolution.
55: * <p>
56: * This means that when a an ambiguous target type is encountered during deserialization of an object (i.e.,
57: * multiple concrete classes match the data type), instead of throwing an {@link
58: * cz.cvut.kbss.jsonld.exception.AmbiguousTargetTypeException}, one of the classes will be selected for
59: * instantiation.
60: * <p>
61: * Note that enabling this behavior should probably be done together with setting {@link #IGNORE_UNKNOWN_PROPERTIES}
62: * to true, so that any JSON-LD data for which the selected target class has no mapping are ignored and do not cause
63: * an exception to be thrown.
64: * <p>
65: * Defaults to {@code false}.
66: */
67: ENABLE_OPTIMISTIC_TARGET_TYPE_RESOLUTION("enableOptimisticTargetTypeResolution"),
68:
69: /**
70: * Configures optimistic type resolution to prefer concrete superclasses if possible.
71: * <p>
72: * If optimistic target type resolution is enabled, the target type resolver will select one of the matching classes
73: * for instantiation. If this parameter is set tot {@code true}, a parent class (if concrete) will be preferred for
74: * instantiation. If not, any of the classes may be selected.
75: * <p>
76: * Defaults to {@code false}.
77: *
78: * @see #ENABLE_OPTIMISTIC_TARGET_TYPE_RESOLUTION
79: */
80: PREFER_SUPERCLASS("preferSuperclass");
81:
82: private final String name;
83:
84: ConfigParam(String name) {
85: this.name = name;
86: }
87:
88: public String getName() {
89: return name;
90: }
91: }